package middleware

import (
	"fmt"
	//"learn-go/learn-go/basic"
	"sync"
	"time"
)

//var logger = basic.XCLogger{}

func init() {
	var arr = [3]int{1, 2, 3}
	var wg sync.WaitGroup

	wg.Add(len(arr))
	for i := range arr {
		go func(i int) {
			worker(i)
			wg.Done()
		}(i)
	}
	wg.Wait()
	logger.Info("DOWN")
}

func worker(id int) {
	once := sync.Once{}
	once.Do(func() {
		
	})
	logger.Info(fmt.Sprintf("Worker %d starting", id))
	time.Sleep(time.Second) // 模拟工作
	logger.Info(fmt.Sprintf("Worker %d done", id))
}
